package com.um.jdy.platform.alarm.controller;

import com.um.jdy.platform.alarm.entity.dto.AlarmRecordPageDTO;
import com.um.jdy.platform.alarm.entity.vo.AlarmRecordItemVO;
import com.um.jdy.platform.alarm.manager.AlarmRecordManager;
import com.um.jdy.common.alarm.entity.dto.AlarmRecordDTO;
import com.um.jdy.common.alarm.entity.po.AlarmRecord;
import com.um.jdy.common.alarm.entity.vo.AlarmRecordVO;
import com.um.jdy.common.alarm.service.AlarmRecordService;
import com.um.springboot.starter.annotation.ApiPermission;
import com.um.springboot.starter.annotation.LoginRequired;
import com.um.springboot.starter.entity.Page;
import com.um.springboot.starter.orm.controller.BasePlusController;
import com.um.springboot.starter.orm.entity.Response;
import com.um.springboot.starter.orm.params.ListDTO;
import com.um.springboot.starter.orm.params.PageParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 控制器：告警记录
 */
@RestController
@RequestMapping("/api/v1/cms/alarm/record")
@Api(tags = "告警记录", description = "告警记录")
@ApiPermission("alarm_record")
@LoginRequired
public class AlarmRecordController extends BasePlusController<AlarmRecordManager, AlarmRecordService, AlarmRecord, AlarmRecordDTO, AlarmRecordVO, AlarmRecordPageDTO, ListDTO> {

    /**
     * 查询分页
     * @param params
     * @return
     */
    @ApiPermission("page")
    @ApiOperation(value = "分页告警记录")
    @PostMapping("/get_page")
    public Response<Page<AlarmRecordItemVO>> getRecordPage(@RequestBody AlarmRecordPageDTO params){
        PageParams pageParams = params.toPageParams(new String[]{"deviceStationId","name","code"},
                new String[]{"r.device_station_id","p.name","p.code"});
        return manager.getRecordPage(pageParams);
    }
}
